import React from 'react';

import './index.less';

export default class Detail extends React.PureComponent {

  componentDidMount() {
    const { content, isLocalHtml } = this.props;
    const detailDom = document.querySelector('.detail');
    if (detailDom && isLocalHtml) {
      detailDom.innerHTML = content;
    }
  }

  componentWillReceiveProps({ content }) {
    const { isLocalHtml } = this.props;
    const detailDom = document.querySelector('.detail');
    if (detailDom && isLocalHtml) {
      detailDom.innerHTML = content;
    }
  }

  render() {
    const { content, isLocalHtml } = this.props;

    return (
      <div className="detail">
        { isLocalHtml && <div dangerouslySetInnerHTML={{__html: content}} /> }
      </div>
    )
  }
}